home *** CD-ROM | disk | FTP | other *** search
/ Alles Voor Internet / Tout Pour Internet / alles voor internet.iso / MacInternet™ / Telnet / NCSA / tn3270 2.4d7 source / NCSA⁄BYU TCP⁄IP / datalayer.c < prev    next >
Text File  |  1991-06-27  |  4KB  |  146 lines

  1. /*  FastNet Box 2            */
  2. /*  Data Layer routines        */
  3.  
  4. #define SCSI_MASTER
  5.  
  6. #include <stdio.h>
  7.  
  8. #include <Dialogs.h>
  9. #include <SCSI.h>
  10.  
  11. #include "BoxLayer.h"
  12. #include "configrec.h"
  13. #include "maclook.h"
  14.  
  15. #define RouterProtocol    0x6003
  16.  
  17.  
  18. unsigned int decAddr;
  19.  
  20. unsigned char nodeAddress[6]=    {0x08,0x00,0x89,0xf0,0x05,0xaf};
  21. unsigned char allRouters[6]=    {0xAB,0x00,0x00,0x03,0x00,0x00};
  22. unsigned char allEndnodes[6]=    {0xAB,0x00,0x00,0x04,0x00,0x00};
  23.  
  24. unsigned char cmdCommand[CMD_LENGTH]=    {SENDING_COMMAND,0};
  25. unsigned char reqCommand[CMD_LENGTH]=    {REQUEST_DATA,0};
  26. unsigned char sendCommand[CMD_LENGTH]=    {SENDING_DATA,0};
  27. unsigned char addrCommand[CMD_LENGTH]=    {REQUEST_ADDR,0};
  28. char temp[50];
  29.  
  30. void DoBoxCommand
  31.   (
  32.     void *theBufferPtr,
  33.     int theLength
  34.   )
  35. {
  36. SCSIInstr tibBlock[2];
  37. short status,message;
  38.     while(SCSIGet());                                /* Arbitration */
  39.     while(SCSISelect(SCSI_ID));                        /* Selection */
  40.     SCSICmd(&cmdCommand[0],CMD_LENGTH);                /* Command */
  41.     tibBlock[0].scOpcode=scNoInc;
  42.     tibBlock[0].scParam1=(long)theBufferPtr;
  43.     tibBlock[0].scParam2=(long)theLength;
  44.     tibBlock[1].scOpcode=scStop;
  45.     tibBlock[1].scParam1=0;
  46.     tibBlock[1].scParam2=0;
  47.     SCSIWrite((Ptr) tibBlock);                            /* Data */
  48.     SCSIComplete(&status,&message,60L);                /* Completion */
  49. }
  50.  
  51. int DoBoxAddrRequest
  52.   (
  53.     unsigned char *theBufferPtr
  54.   )
  55. {
  56.     SCSIInstr tibBlock[3];
  57.     short status,message;
  58.  
  59.     putln("in box request");
  60.     while(SCSIGet());                                /* Arbitration */
  61.     while(SCSISelect(SCSI_ID));                        /* Selection */
  62.     SCSICmd(&addrCommand[0],CMD_LENGTH);                /* Command */
  63.     putln("Command called ");
  64.     tibBlock[0].scOpcode=scNoInc;
  65.     tibBlock[0].scParam1=(long)theBufferPtr;
  66.     tibBlock[0].scParam2=(long)6;                    /* Fixed length - 6 bytes */
  67.     tibBlock[1].scOpcode=scStop;
  68.     tibBlock[1].scParam1=0;
  69.     tibBlock[1].scParam2=0;
  70.     putln("Calling Read");
  71.     SCSIRead((Ptr) tibBlock);                            /* Data */
  72.     putln("Calling completion");
  73.     SCSIComplete(&status,&message,60L);                /* Completion */
  74.     putln("Done....");
  75.     return(status);
  76. }
  77.  
  78. int DoBoxDataRequest    /* Returns packet length or zero */
  79.   (
  80.     void *theBufferPtr
  81.   )
  82. {
  83. SCSIInstr tibBlock[3];
  84. short status,message;
  85.     while(SCSIGet());                                /* Arbitration */
  86.     while(SCSISelect(SCSI_ID));                        /* Selection */
  87.     SCSICmd(&reqCommand[0],CMD_LENGTH);                /* Command */
  88.     tibBlock[0].scOpcode=scNoInc;
  89.     tibBlock[0].scParam1=((long)&tibBlock[1].scParam2)+2;
  90.     tibBlock[0].scParam2=(long)2;
  91.     tibBlock[1].scOpcode=scNoInc;
  92.     tibBlock[1].scParam1=(long)theBufferPtr;
  93.     tibBlock[1].scParam2=0;                            /* Length of data */
  94.     tibBlock[2].scOpcode=scStop;
  95.     tibBlock[2].scParam1=0;
  96.     tibBlock[2].scParam2=0;
  97.     SCSIRead((Ptr) tibBlock);                            /* Data */
  98.     SCSIComplete(&status,&message,60L);                /* Completion */
  99.     return(tibBlock[1].scParam2);
  100. }
  101.  
  102.  
  103. void DoBoxDataSend
  104.   (
  105.     void *theBufferPtr,
  106.     int theLength
  107.   )
  108. {
  109. SCSIInstr tibBlock[3];
  110. short status,message;
  111.     while(SCSIGet());                                /* Arbitration */
  112.     while(SCSISelect(SCSI_ID));                        /* Selection */
  113.     SCSICmd(&sendCommand[0],CMD_LENGTH);            /* Command */
  114.     tibBlock[0].scOpcode=scNoInc;
  115.     tibBlock[0].scParam1=(long)&theLength;
  116.     tibBlock[0].scParam2=(long)2;
  117.     tibBlock[1].scOpcode=scNoInc;
  118.     tibBlock[1].scParam1=(long)theBufferPtr;
  119.     tibBlock[1].scParam2=(long)theLength;
  120.     tibBlock[2].scOpcode=scStop;
  121.     tibBlock[2].scParam1=0;
  122.     tibBlock[2].scParam2=0;
  123.     SCSIWrite((Ptr) tibBlock);                            /* Data */
  124.     SCSIComplete(&status,&message,60L);                /* Completion */
  125. }
  126.  
  127.  
  128. InitializeDataLayer(address)
  129. unsigned int address;
  130. {
  131. DataLinkData lanceData;
  132.  
  133.     /* Initialize address globals (DEC and EtherNet forms) */
  134.     decAddr=address;
  135.     nodeAddress[4]=address;        /* LSB */
  136.     nodeAddress[5]=address>>8;    /* MSB */
  137.  
  138.     lanceData.promiscuousEnable=0;
  139.     lanceData.protocolCount=1;
  140.     lanceData.protocolType[0]=RouterProtocol;
  141.     lanceData.multicastCount=0;
  142.     lanceData.broadcastEnable=1;
  143.     
  144.     DoBoxCommand(&lanceData,sizeof(DataLinkData));
  145. }
  146.